<!doctype html>
<html>
<head>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-K76PSKSSGX"></script>
    <script>
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }

        gtag('js', new Date());

        gtag('config', 'G-K76PSKSSGX');
    </script>
    <meta charset="utf-8">
    <title>人人影视下载分享</title>

    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link href="https://fonts.googleapis.com/css?family=Pacifico&display=swap" rel="stylesheet">
    <link href="/css/normalize.min.css" rel="stylesheet">
    <style>
        h1 {
            font-family: Pacifico, sans-serif;
            font-size: 4em;
            color: #3eb5f1;
            margin: 0;
        }

        h2 {
            font-weight: 300;
            font-family: sans-serif;
        }

        .centered {
            /*position: fixed;*/
            top: 50%;
            left: 50%;
            /*transform: translate(-50%, -50%);*/
            text-align: center;
        }

        #ferris {
            width: 75%;
        }

        /*a::after {*/
        /*    content: attr(title);*/
        /*    display: none;*/
        /*}*/

        /*a:hover::after {*/
        /*    display: block;*/
        /*}*/
        /* Style the tab */
        .tab {
            overflow: hidden;
            border: 1px solid #ccc;

            /*background-color: #f1f1f1;*/
        }

        /* Style the buttons inside the tab */
        .tab button {
            text-align: center;
            background-color: inherit;
            float: inherit;
            border: none;
            outline: none;
            cursor: pointer;
            padding: 14px 16px;
            transition: 0.3s;
            font-size: 17px;
        }

        /* Change background color of buttons on hover */
        .tab button:hover {
            background-color: #ddd;
        }

        /* Create an active/current tablink class */
        .tab button.active {
            background-color: #ccc;
        }

        /* Style the tab content */
        .tabcontent {
            display: none;
            padding: 6px 12px;
            border: 1px solid #ccc;
            border-top: none;
        }

        a {
            text-decoration: none;
        }

        .footer {
            text-decoration: none;
            color: green;
        }
    </style>
</head>
<body>
<div class="centered">
    <h1>人人影视下载分享</h1>
    <h1>By Benny</h1>
    <br>
    <h2>本站数据库<b><a style="color: skyblue" href="https://t.me/mikuri520/668">永久开源免费</a></b>，<abbr
            style="text-decoration: none" title="你也爬不下来啊">请不要做无意义的爬虫。</abbr>
        <a href="help.html" style="color: deepskyblue">使用帮助？</a>
    </h2>

    <form action="search.html">
        <label>
            <input name="kw" type="text">
        </label>
        <input type="submit" value="搜索">
    </form>
    <br>
    <h2>大家都在看🤔……</h2>
    <div class="tab">

    </div>

    <div id="topContent">

    </div>

    <h2>相关资源⬇️</h2>
    <h3>
        联系我 <a class="footer" href="https://t.me/BennyThink">Benny 小可爱</a>・
        YYeTs 机器人<a class="footer" href="https://t.me/yyets_bot">Telegram Bot</a>・
        Telegram <a class="footer" href="https://t.me/mikuri520">Channel</a>・
        开源 <a class="footer" href="https://github.com/tgbot-collection/YYeTsBot">GitHub</a>・
        我的博客 <a class="footer" href="https://dmesg.app/">土豆不好吃</a>
    </h3>
</div>
</body>
<script src="js/axios.min.js"></script>
<script src="js/analytics.js"></script>

<script>
    accessMetrics();

    // get top
    axios.get('/api/top')
        .then(function (response) {
            // handle success
            showTop(response.data)
            // console.log(response.data);
        })
        .catch(function (error) {
            // handle error
            console.log(error);
        })
        .then(function () {
            // always executed
        });


    function showTop(data) {
        const code2Name = data["class"];
        let buttonParent = document.getElementsByClassName("tab")[0]
        let topParent = document.getElementById("topContent")
        delete data["class"];
        for (let code in data) {
            let button = `<button class="tablinks" onclick="openCity(event, '${code}')">${code2Name[code]}</button>`;
            let div = `<div id="${code}" class="tabcontent"></div>`;

            let buttonChild = document.createElement('button');
            buttonChild.innerHTML = button;
            buttonChild = buttonChild.firstChild;
            buttonParent.appendChild(buttonChild);

            let divChild = document.createElement('div');
            divChild.innerHTML = div;
            divChild = divChild.firstChild;
            topParent.appendChild(divChild);

            // render data
            let countryInfo = data[code]
            // let div = HTMLElement
            for (let each in countryInfo) {
                let info = countryInfo[each]["data"]["info"];
                let divParent = document.getElementById(code);
                let name = `${info.cnname} ${info.enname} ${info.aliasname}`;
                let html = `<h4><a title="浏览量 ${info.views}" style="text-decoration: none;color: cornflowerblue" href="/resource.html?id=${info.id}">${name}</a></h4>`;

                let divChild = document.createElement('h4');
                divChild.innerHTML = html;
                divChild = divChild.firstChild;
                divParent.appendChild(divChild);
            }

        }
        document.getElementsByClassName("tab")[0].firstElementChild.className += " active"
        document.getElementById("ALL").style.display = "block"
    }


    function openCity(evt, cityName) {
        var i, tabcontent, tablinks;
        tabcontent = document.getElementsByClassName("tabcontent");
        for (i = 0; i < tabcontent.length; i++) {
            tabcontent[i].style.display = "none";
        }
        tablinks = document.getElementsByClassName("tablinks");
        for (i = 0; i < tablinks.length; i++) {
            tablinks[i].className = tablinks[i].className.replace(" active", "");
        }
        document.getElementById(cityName).style.display = "block";
        console.log(evt)
        evt.currentTarget.className += " active";
    }

</script>
</html>
